<?php

namespace App\Http\Middleware\Api;

use App\Api\Helpers\ApiResponse;
use App\Models\User;
use Closure;

class AuthToken
{
    use ApiResponse;
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
         $user_openid = $request->weixin_openid;
         $user_data = User::where('weixin_openid',$user_openid)->first();

         if(empty($user_data)){
             return $this->failed('没有此用户信息','403');
         }

        return $next($request);
    }
}
